package com.zl.smartmall.library.listener;

import org.apache.http.Header;
import org.json.JSONException;
import org.json.JSONObject;
import com.zl.smartmall.library.util.CrashHandler;

/**
 * 完成维修数据请求监听类
 * @author 陈希然
 *
 */
public abstract class EquimentConfirmListener extends BaseListener {

	private static final String TAG = EquimentConfirmListener.class.getSimpleName();
	@Override
	public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
		
		try {
			int ret = response.getInt("ret");
			switch (ret) {
			case 0:
				onResponseSuccess();
				break;
			case 2:
				onOffline();
				break;

			default:
				onResponseFailed();
				break;
			}
		} catch (JSONException e) {
			e.printStackTrace();
			onResponseFailed();
		}
	}
	
	@Override
	public void onFailure(int statusCode, Header[] headers,
			Throwable throwable, JSONObject errorResponse) {
		// TODO Auto-generated method stub
		CrashHandler.e(throwable);
		onResponseFailed();
	}
	
	/**
	 * 完成维修成功回调
	 */
	public abstract void onResponseSuccess();

	
	
}
